# -!- coding: utf-8 -!-
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
1.获取渠道资金项目数据库的信息生成相应的对账文件
2.获取数据库信息并对信息进行组合
3.更新数据库字段信息
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

from msydwork.config.config_channel_fund import cursor,db


# 财货通通过业务流水号 request_id 获取订单号 apply_no
def get_order(request_id):
    cursor.execute('select apply_no from apply_record_cht where request_id = "%s";' %(request_id))
    try:
        order_no = cursor.fetchone()  # 获取一条数据
        db.commit()
        #print (order_no[0])
        return(order_no[0])
    except:
        print('查无数据！')


# 财货通通过签署成功状态 获取订单号 apply_no
def get_orders():
    cursor.execute('select apply_no from loan_record_cht where result = "S";')
    try:
        order_no = cursor.fetchall()  # 获取多条数据
        db.commit()
        orders = []
        for order in order_no:
            orders.append(order[0])
        #print (orders)
        return(orders)
    except:
        print('查无数据！')


if __name__ == '__main__':
    # get_order('APCHT00120201214002')
    get_orders()

